/**
 * iWeb2GooglePages - Converts export iWeb content and uploads it to GPs.
 * Copyright (C) 2008 Will Droste
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
package org.iweb2gps;

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

/**
 * Wrapper around the preference class.
 */
public class AppPreferences {
    /**
     * Load the preferences for the user.
     */
    private final static Preferences prefs = Preferences
            .userNodeForPackage(AppPreferences.class);

    public AppPreferences() throws BackingStoreException {
        prefs.sync();
    }

    // =======================================================================
    // User Name
    // =======================================================================
    private static final String USERNAME_PROP = "userName";

    public String getUserName() {
        return prefs.get(USERNAME_PROP, "");
    }

    public void setUserName(String value) {
        prefs.put(USERNAME_PROP, value);
    }

    // =======================================================================
    // Password
    // =======================================================================
    private static final String PASSWORD_PROP = "password";

    public String getPassword() {
        return prefs.get(PASSWORD_PROP, "");
    }

    public void setPassword(String value) {
        prefs.put(PASSWORD_PROP, value);
    }

    // =======================================================================
    // Domain
    // =======================================================================
    private static final String DOMAIN_PROP = "domain";

    public String getDomain() {
        return prefs.get(DOMAIN_PROP, null);
    }

    public void setDomain(String value) {
        prefs.put(DOMAIN_PROP, value);
    }

    // =======================================================================
    // Export Directory
    // =======================================================================
    private static final String EXPORT_PROP = "export";

    public String getExportDirectory() {
        return prefs.get(EXPORT_PROP, null);
    }

    public void setExportDirectory(String value) {
        prefs.put(EXPORT_PROP, value);
    }

    public void sync() throws BackingStoreException {
        prefs.flush();
        prefs.sync();
    }
}
